﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.Customers>" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="CRM.Database.Model" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdAddresses";

                                        settings.KeyFieldName = "IdAddress";
                                        settings.SettingsPager.PageSize = 20;

                                        settings.CallbackRouteValues =
                                         new { Controller = "Customers", Action = "CustomerAddressesAndContacts_Addresses_Callback", customerId = Model.IdCustomer };

                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerType;
                                                                     column.FieldName = "IdAddressesType";
                                                                     column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                                                     var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                                                     if (comboBoxProperties != null)
                                                                     {
                                                                         var col = new AddressesTypesCollection();
                                                                         comboBoxProperties.DataSource = col.AddressesTypesList;
                                                                         //collection.EquipmentTypes;
                                                                         comboBoxProperties.TextField = "LocalizedName";
                                                                         comboBoxProperties.ValueField = "IdAddressesType";
                                                                         comboBoxProperties.ValueType = typeof(int);
                                                                     }
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerLegalEntity;
                                                                     column.FieldName = "LegalEntities.Name";
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerZipCode;
                                                                     column.FieldName = "ZipCode";
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerCountry;
                                                                     column.FieldName = "CountryNameLocalized";
                                                                 });
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.customerRegion;
                                            column.FieldName = "ProfineRegionNameLocalized";
                                        });
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.customerDistrict;
                                            column.FieldName = "RegionNameLocalized";
                                        });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerArea;
                                                                      column.FieldName = "AreasNameLocalized";
                                                                 });
                                        settings.Columns.Add(column =>
                                                                 {
                                                                     column.Caption = Resourses.customerCity;
                                                                     column.FieldName = "SettlementsLocalized";
                                                                 });
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.customerStreet;
                                            column.FieldName = "Street";
                                        });
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.customerHouse;
                                            column.FieldName = "House";
                                        });
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.customerPhone;
                                            column.FieldName = "Phone";
                                        });
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.customerFax;
                                            column.FieldName = "Fax";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.Comments;
                                            column.FieldName = "Comments";
                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsPrimary;
                                            column.FieldName = "IsPrimary";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });
                                    }

    ).Bind(Model.Addresses).GetHtml();%>